package co.com.smart.eagle.client.mvp;

import co.com.smart.eagle.client.activity.CrearAplicacionesActivity;
import co.com.smart.eagle.client.activity.CrearRecursosActivity;
import co.com.smart.eagle.client.activity.CrearRolesActivity;
import co.com.smart.eagle.client.activity.CrearUsuariosActivity;
import co.com.smart.eagle.client.activity.HomeActivity;
import co.com.smart.eagle.client.factory.EagleFactory;
import co.com.smart.eagle.client.place.CrearAplicacionesPlace;
import co.com.smart.eagle.client.place.CrearRecursosPlace;
import co.com.smart.eagle.client.place.CrearRolesPlace;
import co.com.smart.eagle.client.place.CrearUsuariosPlace;
import co.com.smart.eagle.client.place.HomePlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {

	private EagleFactory eagleFactory;

	/**
	 * AppActivityMapper associates each Place with its corresponding
	 * {@link Activity}
	 * 
	 * @param eagleFactory
	 *            Factory to be passed to activities
	 */
	public AppActivityMapper(EagleFactory eagleFactory) {
		super();
		this.eagleFactory = eagleFactory;
	}

	/**
	 * Map each Place to its corresponding Activity. This would be a great use
	 * for GIN.
	 */
	@Override
	public Activity getActivity(Place place) {
		// This is begging for GIN
		if (place instanceof HomePlace) {
			return new HomeActivity(eagleFactory);
		} else if (place instanceof CrearUsuariosPlace) {
			return new CrearUsuariosActivity(eagleFactory);
		}else if(place instanceof CrearRolesPlace){
			return new CrearRolesActivity(eagleFactory);
		}else if(place instanceof CrearAplicacionesPlace){
			return new CrearAplicacionesActivity(eagleFactory);
		}else if(place instanceof CrearRecursosPlace){
			return new CrearRecursosActivity(eagleFactory);
		}

		return null;
	}

}
